package com.itheima.health.controller.admin;

import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.result.PageResult;
import com.itheima.health.result.QueryPageBean;
import com.itheima.health.result.Result;
import com.itheima.health.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
@Slf4j
public class StemealController {
    @Autowired
    private SetmealService setmealService;
    /*
    * 新增套餐
    * */
    @PostMapping("/add")
    public Result addSetmeal(@RequestBody Setmeal setmeal,
                             @RequestParam("checkgroupIds")List<String> checkgroupIds){
            setmealService.Addsetmeal(setmeal,checkgroupIds);
            return new Result(true, MessageConst.ADD_SETMEAL_SUCCESS);
    }
    /*
    * 套餐分页查询
    * */
    @GetMapping("/findPage")
    public Result findAll(QueryPageBean queryPageBean){
       PageResult pageResult = setmealService.findall(queryPageBean);
       return  new Result(true,MessageConst.ACTION_SUCCESS,pageResult);
    }
}
